/**
 * 
 */
package com.thon.dao.project.impl;


import java.util.List;

import org.springframework.stereotype.Repository;

import com.thon.dao.project.ProductDao;
import com.thon.dao.util.AbstractDao;
import com.thon.dao.util.Page;
import com.thon.entity.project.Product;

/**
 * @file ProductDaoImpl.java
 * @author Zemo
 * @mail zemochen@gmail.com
 * @data 2013年10月11日 上午11:32:53
 * @description: TODO
 */
@Repository
public class ProductDaoImpl extends AbstractDao<Product> implements ProductDao{
	
	public ProductDaoImpl(){
		super(Product.class);
	}
	
	@Override
	public Page<Product> findProductByProject(Page<Product> page,Integer projectId,Integer isShowAll) {
		
		String queryString;
		if(isShowAll==0)
			queryString = "FROM Product p WHERE p.projectId=? and p.permissions = 'yes'";
		else
			queryString = "FROM Product p WHERE p.projectId=?";
		return findPage(page, queryString, projectId);
	}

	@Override
	public List<Product> listProductsByProject(int projectId) {
		
		String queryString = "FROM Product p WHERE p.projectId = ?";
		return findList(queryString, null, projectId);
	}
}
